/********************************************************************************
 * Copyright (C) 2017, 2018 TypeFox and others.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v. 2.0 which is available at
 * http://www.eclipse.org/legal/epl-2.0.
 *
 * This Source Code may also be made available under the following Secondary
 * Licenses when the conditions for such availability set forth in the Eclipse
 * Public License v. 2.0 are satisfied: GNU General Public License, version 2
 * with the GNU Classpath Exception which is available at
 * https://www.gnu.org/software/classpath/license.html.
 *
 * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
 ********************************************************************************/

/*-----------------------------------------------------------------------------
| Variables
|----------------------------------------------------------------------------*/

:root {
  --theia-private-menubar-height: 32px;
  --theia-private-menu-item-height: 24px;
  --theia-menu-z-index: 10000;
}

/*-----------------------------------------------------------------------------
| MenuBar
|----------------------------------------------------------------------------*/

.p-Widget.p-MenuBar {
  display: flex;
  align-items: center; 
  padding-left: 5px;
  font-size: var(--theia-ui-font-size1);
}

.p-MenuBar-menu {
  transform: translateY(calc(-2 * var(--theia-border-width)));
}

.p-MenuBar-content {
  display: flex;
  align-items: center; 
}

.p-MenuBar-item {
  padding: 0px 8px;
  line-height: var(--theia-content-line-height);
  border-radius: 4px;
}

.p-MenuBar-item .p-MenuBar-itemLabel {
  white-space: pre;
}

.p-MenuBar-item.p-mod-active {
  background: var(--theia-menubar-selectionBackground);
  color: var(--theia-menubar-selectionForeground);
  opacity: 1;
}

.p-MenuBar.p-mod-active .p-MenuBar-item.p-mod-active {
  z-index: calc(var(--theia-menu-z-index) - 1);
  background: var(--theia-menubar-selectionBackground);
  border-left: var(--theia-border-width) solid
    var(--theia-menubar-selectionBorder);
  border-right: var(--theia-border-width) solid
    var(--theia-menubar-selectionBorder);
}

.p-MenuBar-item.p-mod-disabled {
  opacity: var(--theia-mod-disabled-opacity);
}

.p-MenuBar-item.p-type-separator {
  margin: 2px;
  padding: 0;
  border: none;
  border-left: var(--theia-border-width) solid
    var(--theia-menu-separatorBackground);
}

.p-MenuBar-itemMnemonic {
  text-decoration: underline;
}

#theia-top-panel {
  background: var(--theia-titleBar-activeBackground);
  color: var(--theia-titleBar-activeForeground);
  display: flex;
  min-height: var(--theia-private-menubar-height);
  border-bottom: 1px solid var(--theia-titleBar-border);
}
#theia-top-panel:window-inactive,
#theia-top-panel:-moz-window-inactive {
  background: var(--theia-titleBar-inactiveBackground);
  color: var(--theia-titleBar-inactiveForeground);
}

/*-----------------------------------------------------------------------------
| Menu
|----------------------------------------------------------------------------*/

.p-Menu {
  z-index: var(--theia-menu-z-index);
  padding: 4px;
  background: var(--theia-menu-background);
  color: var(--theia-menu-foreground);
  font-size: var(--theia-ui-font-size1);
  box-shadow: 0px 1px 6px var(--theia-widget-shadow);
  border: 1px solid var(--theia-menu-border);
  border-radius: 5px;
}

.p-Menu:focus {
  outline: none;
}

.p-Menu-item {
  min-height: var(--theia-private-menu-item-height);
  max-height: var(--theia-private-menu-item-height);
  padding: 0px;
  /** 
   * FireFox adds 0.5px to all menu items for some reason
   * Subtracting that amount fixes the behavior on FireFox and doesn't introduce issues on Chromium
   */
  line-height: calc(var(--theia-private-menu-item-height) - 0.5px);
  overflow: hidden;
}

.p-Menu-item.p-mod-active {
  color: var(--theia-menu-selectionForeground);
  border: thin solid var(--theia-menu-selectionBorder);
  opacity: 1;
  cursor: pointer;
}

/** 
 * We cannot apply border-radius on items with `display: table-row` 
 * So we apply it to its first and last child
 */

.p-Menu-item.p-mod-active > div {
  background: var(--theia-menu-selectionBackground);
}

.p-Menu-item.p-mod-active > div:first-child {
  border-top-left-radius: 4px;
  border-bottom-left-radius: 4px;
}

.p-Menu-item.p-mod-active > div:last-child {
  border-top-right-radius: 4px;
  border-bottom-right-radius: 4px;
}

.p-Menu-item.p-mod-disabled {
  opacity: var(--theia-mod-disabled-opacity);
}

.p-Menu-itemIcon {
  width: 21px;
  padding: 0px 2px 0px 4px;
  height: var(--theia-private-menu-item-height);
}

.p-Menu-itemLabel {
  padding: 0px 32px 0px 2px;
}

.p-Menu-itemMnemonic {
  text-decoration: underline;
}

.p-Menu-itemShortcut {
  padding: 0px;
}

.p-Menu-itemSubmenuIcon {
  width: var(--theia-icon-size);
  padding: 0px 10px 0px 0px;
}

.p-Menu-item[data-type="separator"] > div {
  padding: 0;
  height: 9px;
  opacity: 0.36;
}

.p-Menu-item[data-type="separator"] > div::after {
  content: "";
  display: block;
  position: relative;
  top: 4px;
  border-top: var(--theia-border-width) solid
    var(--theia-menu-separatorBackground);
}

.p-Menu-item[data-type="separator"] > div:first-child:after {
  margin-left: -4px;
}

.p-Menu-item[data-type="separator"] > div:last-child::after {
  margin-right: -4px;
}

.p-Menu-itemIcon::before,
.p-Menu-itemSubmenuIcon::before {
  font: normal normal normal 16px/1 codicon;
  display: inline-block;
  text-decoration: none;
  text-rendering: auto;
  text-align: center;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  transform: translateY(20%);
}

.p-Menu-item.p-mod-toggled > .p-Menu-itemIcon::before {
  content: "\eab2";
  transform: scale(0.8) translateY(20%);
}

.p-Menu-item[data-type="submenu"] > .p-Menu-itemSubmenuIcon::before {
  content: "\eab6";
}
